<template>
  <Table :columns="columns" :data="inspectLogData"></Table>
</template>
<script type="text/javascript">
import Fetch from '@/api/request'

export default {
  name: 'InspectLogNode',
  data() {
    return {
      columns: [{
        type: 'index',
        width: 60,
        align: 'center'
      }, {
        title: '巡检项描述',
        key: 'inspectItemDesc'
      }, {
        title: '巡检项阈值',
        key: 'inspectItemThresholds',
        width: 130,
        align: 'center'
      }, {
        title: '巡检项实际值',
        key: 'inspectItemActualValue',
        width: 140,
        align: 'center'
      }, {
        title: '巡检项评分权重',
        key: 'inspectItemWeight',
        width: 140,
        align: 'center'
      }, {
        title: '巡检项结果',
        width: 130,
        align: 'center',
        render: (h, params) => {
          if (params.row.inspectItemResult === '正常') {
            return h('span', {
              style: {
                color: '#65beb2'
              }
            }, '正常')
          } else if (params.row.inspectItemResult === '异常') {
            return h('span', {
              style: {
                color: '#f00'
              }
            }, '异常')
          }
        }
      }],
      inspectLogData: []
    }
  },
  props: {
    row: {
      default: {}
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
     // 获取日志数据
    getData() {
      this.loading = true
      Fetch.get({
        url: '/api/inspect/object/searchObject',
        params: {inspectObjectId: this.row.inspectObjectId}
      }).then((res) => {
        if (res && res.resultCode === 0) {
          this.inspectLog = res.data
          if (res.data && res.data.inspectItemInfoList) {
            this.inspectLogData = res.data.inspectItemInfoList
            this.inspectLogMeta = res.data.inspectItemInfoList
          }
        }
        this.loading = false
      }).catch((err) => {
        this.loading = false
        this.$Message.error({
          content: err.message,
          duration: this.DURATION
        })
      })
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>
